//
//  TiJianListView.m
//  安好
//
//  Created by qinlongqing on 14-8-25.
//  Copyright (c) 2014年 冯凯. All rights reserved.
//

#import "TiJianListView.h"
#import "RankingListViewController.h"
#import "ShiLiTestViewController.h"
#import "SeJueTestViewController.h"
#import "XinLvTestViewController.h"
#import "SupplenessViewController.h"
#import "FistTestViewController.h"



@implementation TiJianListView

float x = 0;
float y = 0;

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
    }
    return self;
}

- (void)willMoveToSuperview:(UIView *)newSuperview{
    if (newSuperview == nil) {
        return;
    }
    self.transform = CGAffineTransformMakeRotation(-M_1_PI/2);
    CGPoint afterCenter = CGPointMake(x, y);
    [UIView animateWithDuration:0.35f delay:0.0f options:UIViewAnimationOptionCurveEaseIn animations:^{
        self.transform = CGAffineTransformMakeRotation(0);
        self.center = afterCenter;
    } completion:^(BOOL finished) {
        
    }];
    [super willMoveToSuperview:newSuperview];
}

- (void)removeFromSuperview{
    CGPoint afterCenter = CGPointMake(x, 1136);
    [UIView animateWithDuration:0.35f delay:0.0 options:UIViewAnimationOptionCurveEaseOut animations:^{
        self.transform = CGAffineTransformMakeRotation(M_1_PI/1.5);
        self.center = afterCenter;
    } completion:^(BOOL finished) {
        [super removeFromSuperview];
    }];
}

// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
    [_shiLiBTN.layer setCornerRadius:2];
    [_seMangBTN.layer setCornerRadius:2];
    [_xinLvBTN.layer setCornerRadius:2];
    [_supplenessBTN.layer setCornerRadius:2];
    [_fistBTN.layer setCornerRadius:2];
}

- (IBAction)doCancelBTN:(id)sender {
    [_tijianRootViewController listDisappear];
    [self removeFromSuperview];
}

- (void)showWithCenter:(CGPoint)center{
    x = center.x;
    y = center.y;
    [self setCenter:CGPointMake(x, -y)];
    [_tijianRootViewController.view addSubview:self];
}

- (IBAction)doRankingListBTN:(id)sender {
    RankingListViewController *rankingListViewController = [[RankingListViewController alloc]init];
    [self.tijianRootViewController.navigationController pushViewController:rankingListViewController animated:YES];
}

- (IBAction)doShiLiBTN:(id)sender {
    ShiLiTestViewController *shiLiTest = [[ShiLiTestViewController alloc]init];
    [self.tijianRootViewController.navigationController pushViewController:shiLiTest animated:YES];
}

- (IBAction)doSeJueBTN:(id)sender {
    SeJueTestViewController *sejueTestViewController = [[SeJueTestViewController alloc]init];
    [self.tijianRootViewController.navigationController pushViewController:sejueTestViewController animated:YES];
}

- (IBAction)doXinLvBTN:(id)sender {
    XinLvTestViewController *xinLv = [[XinLvTestViewController alloc]init];
    [self.tijianRootViewController.navigationController pushViewController:xinLv animated:YES];
}

- (IBAction)doWeightBTN:(id)sender {
    SupplenessViewController *supplenessTest = [[SupplenessViewController alloc]initWithNibName:@"SupplenessViewController" bundle:nil];
    [self.tijianRootViewController.navigationController pushViewController:supplenessTest animated:YES];
}

- (IBAction)doFistBTN:(id)sender {
    FistTestViewController *fistTest = [[FistTestViewController alloc]initWithNibName:@"FistTestViewController" bundle:nil];
    [self.tijianRootViewController.navigationController pushViewController:fistTest animated:YES];
}

@end
